package ar.com.sne.model.composer.per;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.api.Textbox;

import foundation.common.util.FinderFilter;
import foundation.common.util.PagedFinder;
import foundation.web.flow.AbstractPagingComposer;
import ar.com.sne.model.service.per.PerClienteService;


@Service
@Scope("prototype")
public class AdministracionClienteComposer  extends
AbstractPagingComposer {
	
	private final Log log = LogFactory.getLog(getClass());
	
	public Textbox tboxApellido,tboxCuit,tboxTipo;
	
	@Resource
	private PerClienteService perClienteService;
	
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		// TODO Auto-generated method stub
		super.doAfterCompose(comp);
	}
	
	
	@Override
	protected PagedFinder searchPaging(PagedFinder pf) {
		return perClienteService.findPaging(pf);
	}
	
	
	@Override
	protected FinderFilter setterFilters() {
		FinderFilter filter = new FinderFilter();
		filter.addFilter("cuit",  tboxCuit.getValue());
		filter.addFilter("apellido",  tboxApellido.getValue());
//		if (cbbTipoTarjeta.getSelectedIndex()!=0)
//			filter.addFilter("tipoTarjeta",  cbbTipoTarjeta.getObjectSelect());
//		if (cbbMedioCobro.getSelectedIndex()!=0)
//			filter.addFilter("medioCobro",  cbbMedioCobro.getObjectSelect());
		return filter;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @seecoop.foundation.zk.crud.composer.AbstractCRUDManagerComposer#
	 * getEditPageName()
	 */
	protected String getEditPageName() {
		return "edicionCliente";
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @seecoop.foundation.zk.crud.composer.AbstractCRUDManagerComposer#
	 * deleteObject(coop.tecso.foundation.persistence.model.PersistentObject)
	 */
//	@Override
//	protected void deleteObject(PersistentObject objectToDelete) {
//		medioCobroPropuestaPolizaService.delete((MedioCobroPropuestaPoliza) objectToDelete);
//	}

	
	/*
	 * (non-Javadoc)
	 * 
	 * @seecoop.foundation.zk.crud.composer.AbstractCRUDManagerComposer#
	 * clearFilterCriteriaFields()
	 */
	@Override
	protected void clearFilterCriteriaFields() {
		tboxCuit.setValue(null);
		tboxApellido.setValue(null);
//		cbbMedioCobro.ListValue(CommonWebUtil.getProperty("combobox.value.todos"));
//		cbbTipoTarjeta.ListValue(CommonWebUtil.getProperty("combobox.value.todos"));
	}


	public PerClienteService getPerClienteService() {
		return perClienteService;
	}


	public void ListPerClienteService(PerClienteService perClienteService) {
		this.perClienteService = perClienteService;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @seecoop.foundation.zk.crud.composer.AbstractCRUDManagerComposer#
	 * getObjectDescription
	 * (coop.tecso.foundation.persistence.model.PersistentObject)
	 */
//	protected String getObjectDescription(PersistentObject objectToDelete) {
//		//TODO this is a generated example 
//		return "";
//	}
	
	

	
}
